<?php

/**
 * JingYao-backend
 *
 * @link     https://gitee.com/wang-zhihui-release/jingyao-backend
 * @apiDocument https://gitee.com/wang-zhihui-release/jingyao-backend/wikis/
 */

namespace Database\Seeders;

use App\Enums\UserIdentityEnum;
use App\Models\House;
use App\Models\HouserScore;
use App\Models\HouseUserBind;
use App\Models\User;
use App\Models\UserProfile;
use Illuminate\Database\Seeder;

class HouserScoreSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run()
    {
        User::factory()->times(100)->create([
            'identity' => UserIdentityEnum::HOUSER,
        ]);

        // 创建 10 个房子
        for ($i = 1; $i < 101; ++$i) {
            UserProfile::factory()->create([
                'user_id' => $i,
                'identity' => UserIdentityEnum::HOUSER,
            ]);
            /** @var House $house */
            $house = House::factory()->create([
                'houser_user_id' => $i,
            ]);
            HouseUserBind::factory()->create([
                'house_id' => $house->id,
            ]);
        }
        // 随机打分
        for ($i = 1; $i < 101; ++$i) {
            HouserScore::factory()->create([
                'house_id' => rand(1, 100),
                'user_id' => $i,
                'check_status' => rand(1, 3),
            ]);
        }
    }
}
